﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include <string.h>
int main()
{
	char str[200];
	int count = 0,/*计算单词数*/len = 0,/*长度*/size = 0/*单词长度位*/, max = 0/*单词最大长度*/;
	int now = 0, last = 0;   	//现在位，前一位
	int ser_last = 0;	//用来保存最长单词的尾标
	//读取有空格的字符串
	scanf("%[^\n]", str);
	len = strlen(str);
	for (int i = 0, j = 0; i <= len; i++)
	{
		//检索空格和结束符
		if (str[i] == ' ' || str[i] == '\0')
		{
			//第几位
			now = i + 1;
			size = now - last - 1;//当前单词长度size = 当前位置 - 前一个位置 - 1
			last = i + 1;
			//printf("已过字符数：i = %d,单词长度：size = %d\n",i+1,size);
			if (max < size)
			{
				//ser_now = now;
				ser_last = last;
				max = size;     //记录最大长度
			}
			count++;
			j++;
		}
	}
	printf("单词数量：%d\n", count);
	printf("最长单词:>");
	for (int i = ser_last - 1 - max; i < ser_last - 1; i++)
	{
		printf("%c", str[i]);
	}
	printf("\n");
	printf("单词最长长度位：%d\n", max);
	return 0;
}